using System.Collections.Generic;
using UnityEngine;

public class FriendProgressDisplayDialog : MonoBehaviour
{
	public UILabel stageNameLabel;

	public UIScrollView scrollView;

	public UITable table;

	public GameObject progressCardButtonPrefab;

	private List<FriendDetailedProgressCard> progressCardButtons = new List<FriendDetailedProgressCard>();

	private bool isAligned;

	public void Show(List<FriendProfileButton> profileButtons, string stageName)
	{
		UITools.ChangeText(stageNameLabel, stageName);
		for (int i = 0; i < profileButtons.Count; i++)
		{
			if (i >= progressCardButtons.Count)
			{
				FriendDetailedProgressCard component = NGUITools.AddChild(table.gameObject, progressCardButtonPrefab).GetComponent<FriendDetailedProgressCard>();
				component.gameObject.name = GGFormat.IndexName(i);
				progressCardButtons.Add(component);
			}
			progressCardButtons[i].Init(profileButtons[i]);
		}
		for (int j = profileButtons.Count; j < progressCardButtons.Count; j++)
		{
			progressCardButtons[j].gameObject.SetActive(false);
		}
		table.Reposition();
		isAligned = false;
		NavigationManager.instance.PushModal(base.gameObject);
	}

	private void Update()
	{
		if (!isAligned && progressCardButtons.Count > 0)
		{
			UITools.AlignToLeftOnScroll(progressCardButtons[0].gameObject.GetComponent<UIWidget>(), scrollView, 0f);
			isAligned = true;
		}
	}
}
